home *** CD-ROM | disk | FTP | other *** search
/ Aminet 2 / Aminet AMIGA CDROM (1994)(Walnut Creek)[Feb 1994][W.O. 44790-1].iso / Aminet / dev / asm / TBSource.lha / NBBS / Utilities / Digitaline.S < prev   
Text File  |  1993-07-02  |  4KB  |  220 lines

  1. ***********************************************
  2. *                          *
  3. *              (C)opyright 1991               *
  4. *                          *
  5. *             by  Tomi Blinnikka              *
  6. *                          *
  7. *      Don´t try to understand the code       *
  8. *                          *
  9. *                          *
  10. *    This is just a program that turns     *
  11. *    the on/off the special stuff with     *
  12. *    a so called digital phoneline          *
  13. *                          *
  14. ***********************************************
  15.  
  16.     INCLUDE    "JMPLibs.i"
  17.     INCLUDE    "exec/types.i"
  18.     INCLUDE    "exec/io.i"
  19.     INCLUDE    "libraries/dos.i"
  20.     INCLUDE    "devices/serial.i"
  21.  
  22.     INCLUDE    "dos.xref"
  23.     INCLUDE    "gfx.xref"
  24.     INCLUDE    "intuition.xref"
  25.     INCLUDE    "exec.xref"
  26.  
  27.     XREF    _CreatePort
  28.     XREF    _DeletePort
  29.     XREF    _CreateExtIO
  30.     XREF    _DeleteExtIO
  31.     XREF    _printf
  32.  
  33.     XDEF    _DOSBase
  34.     XDEF    _SysBase
  35.     XDEF    _stdout
  36.  
  37. Start:        move.l    a0,OptionAddress    ;Get intputs from user
  38.         clr.b    -1(a0,d0.l)        ;add null to end of text
  39.         openlib    Dos,ShutDown
  40.         move.l    _DosBase(pc),_DOSBase
  41.         move.l    $4,_SysBase
  42.  
  43.         lib    Dos,Output
  44.         move.l    d0,_stdout
  45.  
  46.         move.l    OptionAddress(pc),a0
  47.         tst.b    (a0)
  48.         beq    NoCMD
  49.         cmp.b    #"?",(a0)
  50.         beq    CommandLineHelp
  51.         cmp.w    #"-?",(a0)
  52.         beq    CommandLineHelp
  53.         cmp.w    #"-h",(a0)
  54.         beq    CommandLineHelp
  55.         cmp.w    #"-k",(a0)
  56.         bne    Start1
  57.         move.w    #$00,Status
  58.         jmp    Start_END
  59. Start1:        cmp.w    #"-t",(a0)
  60.         bne    CommandLineHelp
  61.         move.w    #$01,Status
  62.  
  63. Start_END:
  64.  
  65. ;Create reply port for serial.device (or modem0.device etc.)
  66.  
  67.         move.l    #0,-(sp)
  68.         pea    SRPortName        ;S(erial)R(eply)PortName
  69.         jsr    _CreatePort
  70.         add.l    #8,sp
  71.         move.l    d0,SRPort
  72.         beq    ShutDown
  73.  
  74. ;Create IOReq for serial.device (or for other device, but size is EXTSER)
  75.  
  76.         move.l    #IOEXTSER_SIZE,-(sp)
  77.         move.l    d0,-(sp)
  78.         jsr    _CreateExtIO
  79.          add.l    #8,sp
  80.         move.l    d0,SerDevIO
  81.         bne    OpenSer
  82.         print    <"Couldn't get SerialIOReq!",13,10>,_stdout
  83.         jmp    ShutDown
  84.  
  85. ;open serial.device
  86.  
  87. OpenSer:    move.w    #$00,SerOpen
  88.         lea.l    SerName(pc),a0
  89.         move.l    SerUnit(pc),d0
  90.         move.l    SerDevIO(pc),a1
  91.         move.b    #SERF_SHARED,IO_SERFLAGS(a1)
  92.         move.l    #$00,d1                ;no flags
  93.         lib    Exec,OpenDevice
  94.         tst.l    d0
  95.         beq    OpenSer1
  96.         print    <"Couldn't open requested device!",13,10>,_stdout
  97.         jmp    ShutDown
  98.  
  99. OpenSer1:    move.w    #$1,SerOpen        ;just to tell if open
  100.         move.l    SRPort(pc),a1
  101.         move.l    #00,d1
  102.         move.b    MP_SIGBIT(a1),d1
  103.         bset.l    d1,WaitMask
  104.  
  105. SendCom:    move.l    SerDevIO(pc),a1
  106.         move.w    #CMD_WRITE,IO_COMMAND(a1)
  107.         move.l    #-1,IO_LENGTH(a1)
  108.         cmp.w    #$01,Status
  109.         bne    SendCom1
  110.         lea.l    TransferOff(pc),a0
  111.         jmp    SendCom2
  112. SendCom1:    lea.l    KnockOff(pc),a0
  113. SendCom2:    move.l    a0,IO_DATA(a1)
  114.         lib    Exec,SendIO
  115.  
  116.         move.l    WaitMask(pc),d0
  117.         lib    Exec,Wait
  118.  
  119.         move.l    SerDevIO(pc),a1
  120.         lib    Exec,CheckIO
  121.         tst.l    d0
  122.         bne    SendCom3
  123.         move.l    SerDevIO(pc),a1
  124.         lib    Exec,AbortIO
  125. SendCom3:    move.l    SerDevIO(pc),a1
  126.         lib    Exec,WaitIO
  127.  
  128. CloseSer:    move.l    SerDevIO(pc),a1
  129.         lib    Exec,CloseDevice
  130.         move.w    #$00,SerOpen
  131.  
  132.         move.l    #IOEXTSER_SIZE,-(sp)
  133.         move.l    SerDevIO(pc),-(sp)
  134.         jsr    _DeleteExtIO
  135.         add.l    #8,sp
  136.         move.l    #$00,SerDevIO
  137.  
  138.         move.l    SRPort(pc),-(sp)
  139.         jsr    _DeletePort
  140.         add.l    #4,sp
  141.         move.l    #$00,SRPort
  142.         jmp    ShutDown8800
  143.  
  144. ShutDown:    tst.l    SerOpen
  145.         beq    ShutDown9000
  146.         move.l    SerDevIO(pc),a1
  147.         lib    Exec,CloseDevice
  148.         
  149. ShutDown9000:    move.l    SerDevIO(pc),d0
  150.         tst.l    d0
  151.         beq    ShutDown8900
  152.         move.l    #IOEXTSER_SIZE,-(sp)
  153.         move.l    d0,-(sp)
  154.         jsr    _DeleteExtIO
  155.         add.l    #8,sp
  156.  
  157. ShutDown8900:    move.l    SRPort(pc),d0
  158.         tst.l    d0
  159.         beq    ShutDown8800
  160.         move.l    d0,-(sp)
  161.         jsr    _DeletePort
  162.         add.l    #4,sp
  163.  
  164. ShutDown8800:
  165. ShutDown8700:
  166. ShutDown1000:    closlib    Dos
  167.  
  168. ShutDownOut:    move.l    #RETURN_OK,d0
  169.         rts
  170.  
  171.         INCLUDE    "LWF:NBBS/Utilities/DiCommandLineHelp.i"
  172.  
  173. ;bits
  174.  
  175. WaitMask    dc.l    SIGBREAKF_CTRL_C
  176.  
  177. ;Structures
  178.  
  179. _DOSBase     dc.l    0
  180. _SysBase    dc.l    0
  181.  
  182.         libnames
  183. ;file stuff
  184.  
  185. _stdout        dc.l    0            ;ex. outfile
  186. OptionAddress    dc.l    0
  187.  
  188. ;device stuff
  189.  
  190. SerOpen        dc.w    0            ;Equals 1 if open
  191. SerDevIO    dc.l    0
  192. SerUnit        dc.l    0
  193. SerName        dc.b    "modem0.device",0
  194.         ds.l    0
  195.  
  196. ;port stuff
  197.  
  198. SRPortName    dc.b    "Digitaline_SerialPort",0
  199.         ds.l    0
  200. SRPort        dc.l    0
  201.  
  202. ;other stuff XIV
  203.  
  204. Status:        dc.w    0        ;0=Knock, 1=transfer
  205.  
  206. ;debug stuff
  207.  
  208. fstr        dc.b    "$%lx",10,0
  209.         ds.l    0
  210. KnockOff:    dc.b    "ATDT#43#",13,0
  211.         ds.l    0
  212. KnockOn:    dc.b    "ATDT*43#",13,0
  213.         ds.l    0
  214. TransferOn:    dc.b    "ATDT*21*4582088#"
  215.         ds.l    0
  216. TransferOff:    dc.b    "ATDT#21#",13,0
  217.         ds.l    0
  218.  
  219.         END
  220.